<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/

//Route::get('/', function () {
//    return view('welcome');
//});

//Auth::routes();
//Route::get('/image/grayscale', function(){
//    $img = \Intervention\Image\Facades\Image::make(public_path('uploads/LaravelAcademy.jpg'))->greyscale();
//    return $img->response('jpg');
//});


Route::group(['domain' => '{domain}.lara4.com','middleware' => 'CheckDomain'], function () {
    Route::get('/', 'User\ArticleController@showAll');

    Route::get('article/{id}', 'User\ArticleController@showOne');
    Route::get('/aikla/Note/index', 'User\ArticleController@NoteIndex');
    Route::get('/aikla/case/index', 'User\ArticleController@CaseIndex');

    Route::get('/aikla/manager/index', 'User\UserController@managerIndex');
    Route::get('/aikla/team/member/id/{id}', 'User\UserController@teamDetail');
    Route::get('/aikla/team/designer', 'User\UserController@showDesigner');
    Route::get('/aikla/team/presenter', 'User\UserController@showPresenter');
    Route::get('/aikla/team/butler', 'User\UserController@showButler');
    Route::get('/aikla/team/photographer', 'User\UserController@showPhotographer');
    Route::get('/aikla/team/maquilleur', 'User\UserController@showMaquilleur');

    Route::get('/aikla/case/brandlist', 'User\BrandController@showIndex');

    Route::get('aikla/constitute/index', 'User\ImgController@index');

    Route::get('/login', 'HomeController@showLogin');

    Route::group(['middleware' => 'CheckAge'], function () {
        Route::post('/login', 'HomeController@postLogin');
    });

});


Route::group(['middleware' => 'auth'], function () {
    Route::get('/index', 'User\ArticleController@index');

    Route::group(['prefix' => 'Admin'], function () {
        Route::get('Index/logout', 'HomeController@logout');
    });

    Route::get('test', 'TestController@upload');
    Route::post('test', 'TestController@postUpload');


    Route::group(['middleware' => 'CheckPermission'], function () {
        Route::get('aikla/Composition/index', 'User\CompositionController@index');
        Route::get('aikla/Content/show/{id}', 'User\ContentController@show');

        Route::get('Admin/Admin/index', 'HomeController@index');
        Route::get('Admin/Admin/add', 'HomeController@index');

        Route::get('Admin/Article/index', 'User\ArticleController@index');
        Route::get('Admin/Article/add', 'User\ArticleController@show');
        Route::post('Admin/Article/add', 'User\ArticleController@create')->middleware(['CheckImg']);
        Route::get('Admin/Article/dele/id/{id}', 'User\ArticleController@destroy');
        Route::get('Admin/Article/update/id/{id}', 'User\ArticleController@update');
        Route::post('Admin/Article/update/id/{id}', 'User\ArticleController@postUpdate')->middleware(['CheckAdmin','CheckImg']);

        Route::get('Admin/Role/index', 'User\RoleController@index');
        Route::get('Admin/Role/add', 'User\RoleController@add');
        Route::get('Admin/Role/destroy/id/{id}', 'User\RoleController@destroy');
        Route::get('Admin/Role/edit/id/{id}', 'User\RoleController@edit');
        Route::post('Admin/Role/edit/id/{id}', 'User\RoleController@save');
        Route::post('Admin/Role/add', 'User\RoleController@store');

        Route::group(['middleware' => 'ChangeNav'], function () {
            Route::get('Admin/Nav/index', 'User\PermissionController@index');
            Route::get('Admin/Nav/add', 'User\PermissionController@getAdd');
            Route::get('Admin/Nav/del/id/{id}', 'User\PermissionController@destroy');
            Route::post('Admin/Nav/add', 'User\PermissionController@postAdd');
            Route::get('Admin/Nav/edit/id/{id}', 'User\PermissionController@edit');
            Route::post('Admin/Nav/store', 'User\PermissionController@store');
            Route::get('Admin/Nav/add', 'User\PermissionController@getAdd');

            Route::get('Admin/Department/index', 'User\DepartmentController@index');
            Route::get('Admin/Department/add', 'User\DepartmentController@create');
            Route::post('Admin/Department/add', 'User\DepartmentController@store')->middleware(['CheckImg']);
            Route::get('Admin/Department/destroy/id/{id}', 'User\DepartmentController@destroy');
            Route::get('Admin/Department/edit/id/{id}', 'User\DepartmentController@edit');
            Route::post('Admin/Department/edit/id/{id}', 'User\DepartmentController@update')->middleware(['CheckImg']);
        });

        Route::get('Admin/User/index', 'User\UserController@index');
        Route::get('Admin/User/create', 'User\UserController@create');
        Route::post('Admin/User/create', 'User\UserController@store')->middleware(['CheckImg']);
        Route::get('Admin/User/edit/id/{id}', 'User\UserController@edit');
        Route::post('Admin/User/edit/id/{id}', 'User\UserController@update')->middleware(['CheckImg']);
        Route::get('Admin/User/destroy/id/{id}', 'User\UserController@destroy');

        Route::get('Admin/config/index', 'HomeController@config');
        Route::post('Admin/config/index', 'HomeController@store')->middleware(['CheckImg']);

        Route::get('Admin/Brand/index', 'User\BrandController@index');
        Route::get('Admin/Brand/add', 'User\BrandController@create');
        Route::post('Admin/Brand/add', 'User\BrandController@store')->middleware(['CheckImg']);
        Route::get('Admin/Brand/destroy/id/{id}', 'User\BrandController@destroy');
        Route::get('Admin/Brand/edit/id/{id}', 'User\BrandController@edit');
        Route::post('Admin/Brand/edit/id/{id}', 'User\BrandController@update')->middleware(['CheckImg']);

//        Route::resource('Admin/Composition', 'User\CompositionController');//婚礼组成资源路由
        Route::get('Admin/Composition/index', 'User\CompositionController@show');
        Route::get('Admin/Composition/edit/{id}', 'User\CompositionController@edit');
        Route::any('Admin/Composition/update/{id}', 'User\CompositionController@update')->middleware(['CheckImg']);
        Route::get('Admin/Composition/create/', 'User\CompositionController@create');
        Route::any('Admin/Composition/store/', 'User\CompositionController@store')->middleware(['CheckImg']);

        Route::get('Admin/Composition/delete/{id}', 'User\CompositionController@delete');

        Route::get('Admin/Content/look/{id}', 'User\ContentController@look');
        Route::get('Admin/Content/delete/{id}', 'User\ContentController@delete');
//        Route::resource('Admin/Content', 'User\ContentController');//组成内容资源路由
        Route::get('Admin/Content/edit/{id}', 'User\ContentController@edit');
        Route::any('Admin/Content/update/{id}', 'User\ContentController@update')->middleware(['CheckImg']);
        Route::get('Admin/Content/create/', 'User\ContentController@create');
        Route::get('aikla/Content/showAll/{id}', 'User\ContentController@showAll');
        Route::any('Admin/Content/store/', 'User\ContentController@store')->middleware(['CheckImg']);

    });


});

//    Route::get('/vvvv', function() {
//        $img = Image::make('http://www.lara4.com/akl/UI/Aikla/img/logo-s.png')->resize(300, 200);
//        return $img;
//    });

//    Route::get('/', function ($account) {
//        echo $account;
//    });

